@echo off

if exist TestResults (rd TestResults /S /Q & echo Deleted "TestResults ")

goto NewVersion

for /f %%a in ('dir source /b') do (
 if exist source\%%a\bin rd source\%%a\bin /S /Q
 if exist source\%%a\obj rd source\%%a\obj /S /Q
)

for /f %%a in ('dir test /b') do (
 if exist test\%%a\bin rd test\%%a\bin /S /Q
 if exist test\%%a\obj rd test\%%a\obj /S /Q
)

:NewVersion
for /f %%I in ('dir /A:D /B /S') do (
 if /i "%%~nI" == "bin" (
	if exist "%%I" (rd "%%I" /S /Q & echo Deleted "%%I")
 )else if /i "%%~nI" == "obj" (
	if exist "%%I" (rd "%%I" /S /Q & echo Deleted "%%I")
 )
)

pause